//
//  XXMainView.m
//  CameraDemo
//
//  Created by sanfang on 2017/2/18.
//  Copyright © 2017年 ziz. All rights reserved.
//

#import "XXMainView.h"


@interface XXMainView ()

//@property (nonatomic,)

@end

@implementation XXMainView


- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupView];
    }
    return self;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = frame;
        [self setupView];
    }
    return self;
}


-(void)setupView
{
    [self addSubview:self.cameraBtn];
    [self addSubview:self.beautifyBtn];
    [self addSubview:self.torchBtn];
}

-(UIButton *)cameraBtn
{
    if (!_cameraBtn) {
        _cameraBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        CGRect frame = CGRectMake(0, 100, 80, 80);
        [_cameraBtn setFrame:frame];
        CGPoint center = CGPointMake(self.frame.size.width/2, self.frame.size.height *2/5);
        [_cameraBtn setCenter:center];
        UIImage *img =[UIImage imageNamed:@"color01"];
        [_cameraBtn setBackgroundImage:img forState:UIControlStateNormal];
        [_cameraBtn setTitle:@"📷" forState:UIControlStateNormal];
    }
    return _cameraBtn;
}


-(UIButton *)beautifyBtn
{
    if (!_beautifyBtn) {
        _beautifyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        CGRect frame = CGRectMake(0, 100, 80, 80);
        [_beautifyBtn setFrame:frame];
        CGPoint center = CGPointMake(self.frame.size.width/2, self.frame.size.height *3/5);
        [_beautifyBtn setCenter:center];
        UIImage *img =[UIImage imageNamed:@"color02"];
        [_beautifyBtn setBackgroundImage:img forState:UIControlStateNormal];
        [_beautifyBtn setTitle:@"👩" forState:UIControlStateNormal];
    }
    return _beautifyBtn;
}

-(UIButton *)torchBtn
{
    if (!_torchBtn) {
        _torchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        CGRect frame = CGRectMake(0, 100, 80, 80);
        [_torchBtn setFrame:frame];
        CGPoint center = CGPointMake(self.frame.size.width/2, self.frame.size.height *4/5);
        [_torchBtn setCenter:center];
        UIImage *norImg = [UIImage imageNamed:@"color04"];
        UIImage *img =[UIImage imageNamed:@"color03"];
        [_torchBtn setBackgroundImage:norImg forState:UIControlStateNormal];
        [_torchBtn setBackgroundImage:img forState:UIControlStateSelected];
        [_torchBtn setTitle:@"🔦" forState:UIControlStateNormal];
    }
    return _torchBtn;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
